import java.awt.*;
import java.awt.event.*;

import javax.swing.*;



public class VentanaCalculadora extends JFrame  {

	private String textoPantalla="";
	private JTextField pantalla;
	
	public JTextField getTexto() {
		return pantalla;
	}
	
	public void setTexto(String texto) {
		textoPantalla+=texto;
		this.pantalla.setText(textoPantalla);
	}
	public VentanaCalculadora() {
		
		setSize(250,300); 
		setTitle("Calculadora completa");
		
		JPanel panel=new JPanel();
		panel.setLayout(new BorderLayout());
		
		pantalla=new JTextField();
		panel.add(pantalla, BorderLayout.NORTH);
		
		JPanel aux=new JPanel();
		aux.setLayout(new GridLayout(3,4));
		
		BotonNum b0= new BotonNum(0);
		BotonNum b1= new BotonNum(1);
		BotonNum b2= new BotonNum(2);
		BotonNum b3= new BotonNum(3);
		BotonNum b4= new BotonNum(4);
		BotonNum b5= new BotonNum(5);
		BotonNum b6= new BotonNum(6);
		BotonNum b7= new BotonNum(7);
		BotonNum b8= new BotonNum(8);
		BotonNum b9= new BotonNum(9);
		BotonOper b10= new BotonOper("+");
		BotonOper b11= new BotonOper("-");
		BotonOper b12= new BotonOper("*");
		BotonOper b13= new BotonOper("/");
		BotonOper b15= new BotonOper("=");
		
		aux.add(b1);
		aux.add(b2);
		aux.add(b3);
		aux.add(b4);
		aux.add(b10);
		aux.add(b5);
		aux.add(b6);
		aux.add(b7);
		aux.add(b8);
		aux.add(b11);
		aux.add(b9);
		aux.add(b0);
		aux.add(b12);
		aux.add(b13);
		aux.add(b15);

		panel.add(aux,BorderLayout.CENTER);
		getContentPane().add(panel);
		
		ListenerCalculadora c=new ListenerCalculadora(this);
		//Botones de los numeros.
		b0.addActionListener(c);
		b1.addActionListener(c);
		b2.addActionListener(c);
		b3.addActionListener(c);
		b4.addActionListener(c);
		b5.addActionListener(c);
		b6.addActionListener(c);
		b7.addActionListener(c);
		b8.addActionListener(c);
		b9.addActionListener(c);
				
		//Botones de operaciones.
		b10.addActionListener(c);
		b11.addActionListener(c);
		b12.addActionListener(c);
		b13.addActionListener(c);
		b15.addActionListener(c);
				
		
		}

	
		
}
	
	
	
